<?php

namespace Kordar\Tree;

/**
 * Class BinaryNode
 * @package yak\libs\tree
 * 二叉树节点
 */
class BinaryNode
{
    public $data;
    public $left;
    public $right;

    public function __construct($data)
    {
        $this->data = $data;
    }

    // 二叉树的添加
    function buildTree(BinaryNode $left = null, BinaryNode $right = null)
    {
        if (!is_null($left)) {
            $this->left = $left;
        }
        if (!is_null($right)) {
            $this->right = $right;
        }
    }
}